<?php

declare(strict_types=1);

namespace Yolo\Commands;

use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Psr\Container\ContainerInterface;
use Yolo\Di\DI;
use Yolo\Service\ApplicationContainer;

#[Command]
class PreviewConfig extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('config:preview');
    }

    public function configure(): void
    {
        parent::configure();
        $this->setDescription('Preview the application config');
    }

    public function handle(): void
    {
        $container = DI::use(ApplicationContainer::class);
        $this->line(json_encode($container->getConfig()->get(''), JSON_PRETTY_PRINT));
    }
}
